<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>xml介绍</title>
</head>

<body>
    <div class="container">
        <div class="title"></div>
        <div class="content"></div>
        <button id="btn">点我发送请求</button>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        $('#btn').on('click', function () {
            var xhr = new XMLHttpRequest();
            xhr.open('get', '/xml');
            xhr.send();
            xhr.onload = function () {
                const xmlDocument = xhr.responseXML;
                console.log(xmlDocument)
                const ttile = xmlDocument.getElementsByTagName('title')[0];
                const content = xmlDocument.getElementsByTagName('content')[0];
                console.log(ttile, content)
                $('.title').html(ttile)
                $('.content').html(content)
            }
        })
    </script>
</body>

</html>